import {  message } from 'antd';
export function isHavePermission(fun: string): Boolean {
    if(sessionStorage.getItem('userRole')) {
        let role = JSON.parse(sessionStorage.getItem('userRole'));
        return role.includes(fun)
    }
    return false
}
export function isHavePathPermission() {
    const userRole = JSON.parse(sessionStorage.getItem('userRole'));
    const pathName = window.location.hash.slice(1).split('/')[1];
    
    if(pathName === 'Dashboard' || pathName === 'DocumentLibrary' || pathName === 'SearchExportFile' || pathName === 'SearchApplyRegulationsFile' || pathName === 'SearchFile') {
        return false
    }
    if(pathName && !userRole.includes(`${pathName}/disp`)) {
      message.error('暂无权限访问当前页面，请联系管理员', 3, () => {
        location.href =window.location.href.split('#')[0] + '#/' + userRole[0].split('/')[0]
      });
    }
}